from django.db.models import F
from finance.models import Bank, HisBank


def update_account_balance(bank, money):
    if bank and money != 0:
        data = {
            'account_id': bank.id,
            'account_name': bank.account,
            'money': bank.money,
            'desc': bank.desc,
        }
        HisBank.objects.create(**data)
        Bank.objects.filter(id=bank.id).update(money=F("money") + money)
        return True

    return False

